package com.wpp.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wpp.mapper.ArticleMapper;
import com.wpp.pojo.ArticlePO;
import com.wpp.service.ArticleService;
import com.wpp.util.PageUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author by wpp25
 * @Classname ArticleServiceImpl
 * @Description
 * @Date 2020/11/7 11:07
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Resource
    private ArticleMapper articleMapper;

    @Override
    public PageUtil<ArticlePO> listByPage(Integer pageNum,Integer pageSize) {
        List<ArticlePO> articlePOList = articleMapper.listByPage(pageNum - 1, pageSize);
        int totalSize = articleMapper.count();


        PageUtil<ArticlePO> pageUtil = new PageUtil<>(pageNum,pageSize,totalSize,articlePOList);
        return pageUtil;
    }
}
